{{if false}}<script>{{/if}}
{{$controller = $smarty.const.CCTRL}}
{{$token = $smarty.const.TOKEN}}
{{include file="../00_base/function.tpl"}}
function handleEvents(){
    try{
        acolumns['Status'].createeditor=function (row, cellvalue, editor) {
                var dataSource = ['New', 'Confirmed','Canceled'];
                editor.jqxDropDownList({source: dataSource });
        }
        myGrid.bind('cellendedit', function (event) {
            try{
                var args = event.args;
                var _column = args.datafield ,_row = args.rowindex,_value = args.value;
                var _data=myGrid.jqxGrid('getrowdata', _row);
                var _id=_data.ID;
                if(_id==undefined || _id==""){
                    return;
                }
                switch(_column){
                    case "Status":
                        if(_value!=_data.Status)updateCol(_column,_id,_value);
                        break;
                    default:
                        uiMessage("Unkown this cell. Maybe 'editable' of this colums is 'off'."); 
                }
            }catch(e){
                uiMessage(e.message);
                console.log("Error:"+e.message);
            }
        }).bind('cellselect', function (event) {
            var _dataRow=myGrid.jqxGrid('getrowdata', event.args.rowindex);
            var _id=_dataRow._id==undefined?(_dataRow.ID==undefined?_dataRow.ProductID:_dataRow.ID):_dataRow._id;
            if(_id!=undefined){
                
                if($("div#"+_id).length==0){
                    $("#_logs").append(
                        "<div class='order-detail' id='"+_dataRow.ID+"'>\
                            <table>\
                                <tr><td class='w100px'>Time</td><td>"+_dataRow.Insert+"</td></tr>\
                                <tr><td class='w100px'>Tour</td><td>"+_dataRow.Title+"</td></tr>\
                                <tr><td>Name</td><td>"+_dataRow.Name+"</td></tr>\
                                <tr><td>Email</td><td>"+_dataRow.Email+"</td></tr>\
                                <tr><td>Phone</td><td>"+_dataRow.Phone+"</td></tr>\
                                <tr><td>Monney</td><td>$"+_dataRow.Monney+"</td></tr>\
                                <tr><td class='vtat'>Note</td><td><pre>"+_dataRow.Note+"</pre></td></tr>\
                                <tr><td>Status</td><td><tt>"+_dataRow.Status+"</tt></td></tr>\
                            </table>\
                        </div>\
                        "
                    );
                    $(".order-detail").hide();
                $("div#"+_id).fadeIn();
                }else{
                    if($("div#"+_id).is(":hidden")){
                        $(".order-detail").hide();
                        $("div#"+_id).fadeIn();
                        return;
                    }
                }
                
                
            }else{
                $(".order-detail").hide();
            }
        });
    }catch(e){uiMessage(e.message);}
}
